package service.impl;

import dao.ExtractDao;
import entity.Extract;
import org.hibernate.criterion.DetachedCriteria;
import service.ExtractService;

import java.util.List;

public class ExtractServiceImpl implements ExtractService {
    private ExtractDao ed;

    @Override
    public void save(Extract extract) {
        ed.save(extract);
    }

    @Override
    public Extract getExtractByCondition(DetachedCriteria dc) {
        List<Extract> list = ed.getByCondition(dc);
        if (list.isEmpty()){
            return null;
        }else {
            return ed.getByCondition(dc).get(0);
        }
    }

    public void setEd(ExtractDao ed) {
        this.ed = ed;
    }
}
